package com.tencent.stat;

import android.content.Context;
import com.tencent.stat.common.StatLogger;
import com.tencent.stat.event.e;
import com.tencent.stat.event.i;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;
import org.json.JSONArray;

class ar
  implements Runnable
{
  private Context a = null;
  private Map b = null;
  private StatSpecifyReportedInfo c = null;

  public ar(Context paramContext, Map paramMap, StatSpecifyReportedInfo paramStatSpecifyReportedInfo)
  {
    this.a = paramContext;
    this.c = paramStatSpecifyReportedInfo;
    if (paramMap == null)
      return;
    this.b = paramMap;
  }

  // ERROR //
  private NetworkMonitor a(String paramString, int paramInt)
  {
    // Byte code:
    //   0: new 31	com/tencent/stat/NetworkMonitor
    //   3: dup
    //   4: invokespecial 32	com/tencent/stat/NetworkMonitor:<init>	()V
    //   7: astore 6
    //   9: new 34	java/net/Socket
    //   12: dup
    //   13: invokespecial 35	java/net/Socket:<init>	()V
    //   16: astore 7
    //   18: iconst_0
    //   19: istore_3
    //   20: aload 6
    //   22: aload_1
    //   23: invokevirtual 39	com/tencent/stat/NetworkMonitor:setDomain	(Ljava/lang/String;)V
    //   26: aload 6
    //   28: iload_2
    //   29: invokevirtual 43	com/tencent/stat/NetworkMonitor:setPort	(I)V
    //   32: invokestatic 49	java/lang/System:currentTimeMillis	()J
    //   35: lstore 4
    //   37: new 51	java/net/InetSocketAddress
    //   40: dup
    //   41: aload_1
    //   42: iload_2
    //   43: invokespecial 54	java/net/InetSocketAddress:<init>	(Ljava/lang/String;I)V
    //   46: astore_1
    //   47: aload 7
    //   49: aload_1
    //   50: sipush 30000
    //   53: invokevirtual 58	java/net/Socket:connect	(Ljava/net/SocketAddress;I)V
    //   56: aload 6
    //   58: invokestatic 49	java/lang/System:currentTimeMillis	()J
    //   61: lload 4
    //   63: lsub
    //   64: invokevirtual 62	com/tencent/stat/NetworkMonitor:setMillisecondsConsume	(J)V
    //   67: aload 6
    //   69: aload_1
    //   70: invokevirtual 66	java/net/InetSocketAddress:getAddress	()Ljava/net/InetAddress;
    //   73: invokevirtual 72	java/net/InetAddress:getHostAddress	()Ljava/lang/String;
    //   76: invokevirtual 75	com/tencent/stat/NetworkMonitor:setRemoteIp	(Ljava/lang/String;)V
    //   79: aload 7
    //   81: invokevirtual 78	java/net/Socket:close	()V
    //   84: aload 7
    //   86: invokevirtual 78	java/net/Socket:close	()V
    //   89: iload_3
    //   90: istore_2
    //   91: aload 6
    //   93: iload_2
    //   94: invokevirtual 81	com/tencent/stat/NetworkMonitor:setStatusCode	(I)V
    //   97: aload 6
    //   99: areturn
    //   100: astore_1
    //   101: invokestatic 87	com/tencent/stat/StatServiceImpl:f	()Lcom/tencent/stat/common/StatLogger;
    //   104: aload_1
    //   105: invokevirtual 93	com/tencent/stat/common/StatLogger:e	(Ljava/lang/Throwable;)V
    //   108: iload_3
    //   109: istore_2
    //   110: goto -19 -> 91
    //   113: astore_1
    //   114: iconst_m1
    //   115: istore_2
    //   116: invokestatic 87	com/tencent/stat/StatServiceImpl:f	()Lcom/tencent/stat/common/StatLogger;
    //   119: aload_1
    //   120: invokevirtual 93	com/tencent/stat/common/StatLogger:e	(Ljava/lang/Throwable;)V
    //   123: aload 7
    //   125: invokevirtual 78	java/net/Socket:close	()V
    //   128: goto -37 -> 91
    //   131: astore_1
    //   132: invokestatic 87	com/tencent/stat/StatServiceImpl:f	()Lcom/tencent/stat/common/StatLogger;
    //   135: aload_1
    //   136: invokevirtual 93	com/tencent/stat/common/StatLogger:e	(Ljava/lang/Throwable;)V
    //   139: goto -48 -> 91
    //   142: astore_1
    //   143: aload 7
    //   145: invokevirtual 78	java/net/Socket:close	()V
    //   148: aload_1
    //   149: athrow
    //   150: astore 6
    //   152: invokestatic 87	com/tencent/stat/StatServiceImpl:f	()Lcom/tencent/stat/common/StatLogger;
    //   155: aload 6
    //   157: invokevirtual 93	com/tencent/stat/common/StatLogger:e	(Ljava/lang/Throwable;)V
    //   160: goto -12 -> 148
    //
    // Exception table:
    //   from	to	target	type
    //   84	89	100	java/lang/Throwable
    //   20	84	113	java/io/IOException
    //   123	128	131	java/lang/Throwable
    //   20	84	142	finally
    //   116	123	142	finally
    //   143	148	150	java/lang/Throwable
  }

  private Map a()
  {
    HashMap localHashMap = new HashMap();
    Object localObject = StatConfig.a("__MTA_TEST_SPEED__", null);
    if ((localObject == null) || (((String)localObject).trim().length() == 0))
      return localHashMap;
    localObject = ((String)localObject).split(";");
    int j = localObject.length;
    int i = 0;
    while (true)
    {
      String str;
      if (i < j);
      String[] arrayOfString = localObject[i].split(",");
      if ((arrayOfString != null) && (arrayOfString.length == 2))
      {
        str = arrayOfString[0];
        if ((str == null) || (str.trim().length() == 0));
      }
      try
      {
        int k = Integer.valueOf(arrayOfString[1]).intValue();
        localHashMap.put(str, Integer.valueOf(k));
        i += 1;
      }
      catch (NumberFormatException localNumberFormatException)
      {
        while (true)
          StatServiceImpl.f().e(localNumberFormatException);
      }
    }
  }

  public void run()
  {
    while (true)
    {
      Map.Entry localEntry;
      String str;
      try
      {
        if (this.b == null)
          this.b = a();
        if ((this.b == null) || (this.b.size() == 0))
        {
          StatServiceImpl.f().i("empty domain list.");
          return;
        }
        JSONArray localJSONArray = new JSONArray();
        localObject = this.b.entrySet().iterator();
        if (!(((Iterator)localObject).hasNext()))
          break label203;
        localEntry = (Map.Entry)((Iterator)localObject).next();
        str = (String)localEntry.getKey();
        if ((str != null) && (str.length() != 0))
          break label129;
        StatServiceImpl.f().w("empty domain name.");
      }
      catch (Throwable localThrowable)
      {
        StatServiceImpl.f().e(localThrowable);
        return;
      }
      if ((Integer)localEntry.getValue() == null)
        label129: StatServiceImpl.f().w("port is null for " + str);
      localThrowable.put(a((String)localEntry.getKey(), ((Integer)localEntry.getValue()).intValue()).toJSONObject());
    }
    if (localThrowable.length() == 0)
      label203: return;
    Object localObject = new i(this.a, StatServiceImpl.a(this.a, false, this.c), this.c);
    ((i)localObject).a(localThrowable.toString());
    new as((e)localObject).a();
  }
}